//package com.springboot.cloud.auth.authentication.config;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import org.springframework.security.core.AuthenticationException;
//import org.springframework.security.web.AuthenticationEntryPoint;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.HashMap;
//import java.util.Map;
//
//public class AuthExceptionEntryPoint implements AuthenticationEntryPoint {
//    @Override
//    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException)
//        throws ServletException{
//        Map map=new HashMap();
//        map.put("error","401");
//        map.put("message",authException.getMessage());
//        map.put("timestamp",String.valueOf(System.currentTimeMillis()));
//        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
//        try {
//            ObjectMapper mapper=new ObjectMapper();
//            mapper.writeValue(response.getOutputStream(),map);
//        }catch (Exception e){
//            throw new ServletException();
//        }
//    }
//}
